using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
    /// <summary>
    /// Controller class for InternetLog
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class InternetLogController
    {
        // Preload our schema..
        InternetLog thisSchemaLoad = new InternetLog();
        private string userName = string.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}

					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}

				}

				return userName;
            }

        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public InternetLogCollection FetchAll()
        {
            InternetLogCollection coll = new InternetLogCollection();
            Query qry = new Query(InternetLog.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public InternetLogCollection FetchByID(object InternetLogID)
        {
            InternetLogCollection coll = new InternetLogCollection().Where("InternetLogID", InternetLogID).Load();
            return coll;
        }

		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public InternetLogCollection FetchByQuery(Query qry)
        {
            InternetLogCollection coll = new InternetLogCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object InternetLogID)
        {
            return (InternetLog.Delete(InternetLogID) == 1);
        }

        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object InternetLogID)
        {
            return (InternetLog.Destroy(InternetLogID) == 1);
        }

        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(byte? CountryID,DateTime? RFDate,int? MediaCode,int? TimeStart,int? TimeEnd,int? PageNumber,int? InternetBodyCode,string Tipology,decimal? RealCost,double? Wide,int? PageType,double? Length,string ClassCode,int? Pages,string Measure,int? ColorCode,int? ProductID,int ProdVersionID,int? CategoryID,int? SubSectorID,int? SectorID,int? BrandID,int? AdvertiserID,string ImageName,int? AgencyID,DateTime DateAdded,DateTime DateModified)
	    {
		    InternetLog item = new InternetLog();
		    
            item.CountryID = CountryID;
            
            item.RFDate = RFDate;
            
            item.MediaCode = MediaCode;
            
            item.TimeStart = TimeStart;
            
            item.TimeEnd = TimeEnd;
            
            item.PageNumber = PageNumber;
            
            item.InternetBodyCode = InternetBodyCode;
            
            item.Tipology = Tipology;
            
            item.RealCost = RealCost;
            
            item.Wide = Wide;
            
            item.PageType = PageType;
            
            item.Length = Length;
            
            item.ClassCode = ClassCode;
            
            item.Pages = Pages;
            
            item.Measure = Measure;
            
            item.ColorCode = ColorCode;
            
            item.ProductID = ProductID;
            
            item.ProdVersionID = ProdVersionID;
            
            item.CategoryID = CategoryID;
            
            item.SubSectorID = SubSectorID;
            
            item.SectorID = SectorID;
            
            item.BrandID = BrandID;
            
            item.AdvertiserID = AdvertiserID;
            
            item.ImageName = ImageName;
            
            item.AgencyID = AgencyID;
            
            item.DateAdded = DateAdded;
            
            item.DateModified = DateModified;
            
	    
		    item.Save(UserName);
	    }

    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int InternetLogID,byte? CountryID,DateTime? RFDate,int? MediaCode,int? TimeStart,int? TimeEnd,int? PageNumber,int? InternetBodyCode,string Tipology,decimal? RealCost,double? Wide,int? PageType,double? Length,string ClassCode,int? Pages,string Measure,int? ColorCode,int? ProductID,int ProdVersionID,int? CategoryID,int? SubSectorID,int? SectorID,int? BrandID,int? AdvertiserID,string ImageName,int? AgencyID,DateTime DateAdded,DateTime DateModified)
	    {
		    InternetLog item = new InternetLog();
		    
				item.InternetLogID = InternetLogID;
				
				item.CountryID = CountryID;
				
				item.RFDate = RFDate;
				
				item.MediaCode = MediaCode;
				
				item.TimeStart = TimeStart;
				
				item.TimeEnd = TimeEnd;
				
				item.PageNumber = PageNumber;
				
				item.InternetBodyCode = InternetBodyCode;
				
				item.Tipology = Tipology;
				
				item.RealCost = RealCost;
				
				item.Wide = Wide;
				
				item.PageType = PageType;
				
				item.Length = Length;
				
				item.ClassCode = ClassCode;
				
				item.Pages = Pages;
				
				item.Measure = Measure;
				
				item.ColorCode = ColorCode;
				
				item.ProductID = ProductID;
				
				item.ProdVersionID = ProdVersionID;
				
				item.CategoryID = CategoryID;
				
				item.SubSectorID = SubSectorID;
				
				item.SectorID = SectorID;
				
				item.BrandID = BrandID;
				
				item.AdvertiserID = AdvertiserID;
				
				item.ImageName = ImageName;
				
				item.AgencyID = AgencyID;
				
				item.DateAdded = DateAdded;
				
				item.DateModified = DateModified;
				
		    item.MarkOld();
		    item.Save(UserName);
	    }

    }

}

